package org.itli.jnsocket.Mapper;

import org.apache.ibatis.annotations.*;
import org.itli.jnsocket.Pojo.Customer;

import java.util.List;

@Mapper
public interface CustomerMapper {

    //查询所有客户
    @Select("SELECT id, customer_no, customer_name, customer_contact, customer_phone, customer_address, customer_status, order_num, remark " +
            "FROM jn_wms_customer LIMIT #{size} OFFSET #{page}")
    List<Customer> AllCustomers(int size,int page);

    //添加客户
    @Insert("INSERT INTO jn_wms_customer (customer_no, customer_name, customer_contact, customer_phone, customer_address, customer_status, order_num, remark,create_by,create_time,update_by,update_time)" +
            "VALUES (#{customer.customer_no}, #{customer.customer_name}, #{customer.customer_contact}, #{customer.customer_phone}, #{customer.customer_address}, #{customer.customer_status}, #{customer.order_num}, #{customer.remark},#{create_by},NOW(),#{update_by},NOW())")
    int AddCustomers(Customer customer,String update_by,String create_by);

    @Update("UPDATE jn_wms_customer SET " +
            "customer_name = #{customer.customer_name}, " +
            "customer_contact = #{customer.customer_contact}, " +
            "customer_phone = #{customer.customer_phone}, " +
            "customer_address = #{customer.customer_address}, " +
            "customer_status = #{customer.customer_status}, " +
            "order_num = #{customer.order_num}, " +
            "remark = #{customer.remark}, " +
            "update_by = #{update_by}, " +
            "update_time = NOW()," +
            "customer_no = #{customer.customer_no}"+
            "WHERE id = #{customer.id}")
    int UpdateCustomer(Customer customer, String update_by);

    @Delete("delete from jn_wms_customer where id = #{id}")
    int DeleteCustomer(String id);

}
